﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TimeTrak.BLL;

namespace TimeTrak.DAL
{
    class DataAccess
    {
        /// <summary>
        /// Depersist Tasks
        /// </summary>
        /// <returns></returns>
        public List<Task> GetTaskList(string filePath)
        {
            try
            {
                List<Task> list = new List<Task>();

                list = XMLTools.DeserializeFromXML<List<Task>>(filePath);

                return list;
            }
            catch
            {
                //throw new Exception("Error getting the task list!", ex);
                return new List<Task>();
            }

        }

        public void SaveTaskList(List<Task> taskList, string filePath)
        {
            try
            {
                Console.Out.WriteLine("Saving Task List!");
                XMLTools.SerializeToXML(taskList, filePath);
            }
            catch (Exception ex)
            {
                throw new Exception("Error saving the task list!", ex);
            }
        }
    }
}
